#include "stdafx.h"
#include "core/AppRoot.h"
#include "core/Component.h"
#include "core/Entity.h"


TEST(TestCase_AppRoot, Test_AppRoot_main) 
{	
	AppRoot APPROOT;

	HWND hconsole = ::GetConsoleWindow();
	
	PlatformData pdata(
		::GetModuleHandle(NULL),
		hconsole, 
		"");

	EXPECT_NO_THROW( APPROOT.main(pdata) );	
	
}

Console cc;
TEST(TestCase_CONSOLE, Test_CONSOLE_0)
{	
	Console& c = Console::getSingleton();
	
	EXPECT_NO_THROW(EXPECT_TRUE(c.hasInput()));	
	if (c.hasInput())
	{
		String input = c.getInput();
		EXPECT_TRUE(input.length()>0);
	}
	c.print("TEST STDOUT - Printing out to console\n");
}



TEST(TestCase_Components, Test_Components_0) 
{
	//cc.print("TestCase_Components\n");
	class MovableComponentInterface : public BaseComponentInterface<MovableComponentInterface>
	{
	};

	class MovableComponent: public BaseComponent<MovableComponentInterface>
	{
	};


	std::unique_ptr<MovableComponent> mc( new MovableComponent());			
	unsigned id1 = MovableComponentInterface::InterfaceID();	
	std::string s1 = MovableComponentInterface::InterfaceNAME();	
	unsigned id2 = mc->getInterfaceID();
	std::string s2 = mc->getInterfaceNAME();	

	ASSERT_EQ(id1,id2);
	ASSERT_EQ(s2,s1);


	Entity e;
	e.addComponent(mc.get());

	MovableComponentInterface* mci1 = mc->getInterface();		
	MovableComponentInterface* mci2 = e.findInterface<MovableComponentInterface>();			
	ASSERT_TRUE(mci2!=NULL);
	ASSERT_EQ(mci1,mci2);

	e.removeComponent(mc.get());
	MovableComponentInterface* mci3 = e.findInterface<MovableComponentInterface>();
	ASSERT_TRUE(mci3==NULL);

}


#include "input/InputComponent.h"

TEST(TestCase_Input, Test_input_0) 
{
	InputComponent* ic = new InputComponent();	
	InputComponentInterface* ici = ic->getInterface();

	Entity e;
	e.addComponent(ic);

	delete ic;
}